<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 

// @TODO: Get results only where they are set to active

class Source_model extends CI_Model
{
	protected $_table;	    
	/**
	 * Constructor
	 *
	 * @access	public
	 */
	function __construct()
	{
		parent::__construct();
		$this->load->helper('date');
	}
	
	// START SOURCE MODEL
	
	// get list source
	function get_list_source($limit, $start)
	{
		$this->db->select('id, name, status');
		$this->db->from('vt_xuat_xu');
		$this->db->limit($limit, $start);
		$query = $this->db->get();
		return $query->result_array();
	}
	// Get All Source Active
	function get_all_source()
	{
		$this->db->select('id, name, status');
		$this->db->from('vt_xuat_xu');
		$this->db->where('status',1);
		$query = $this->db->get();
		return $query->result_array();
		
	}
	// count all category
	function count_all_source($status = '')
	{
		$this->db->select('id');
		$this->db->from('vt_xuat_xu');
		if($status != "")
		{
			$this->db->where('status',$status);
		}
		return $this->db->count_all_results();
	}
	
	// add category
	function add_source()
	{
		$fields = array(
				'name'			=> $this->input->post('name'),
				'status'		=> 0,
		);
	
		$this->db->set($fields);
		$this->db->insert('vt_xuat_xu');
	}
	
	// Edit category
	public function edit_source($id)
	{
		$fields = array(
				'name'			=> $this->input->post('name')
	
		);
	
		$this->db->set($fields);
		$this->db->where('id', $id);
		$this->db->update('vt_xuat_xu');
	}
	
	// get category
	function get_source($id)
	{
		$this->db->select('*');
		$this->db->from('vt_xuat_xu');
		$this->db->where('id',$id);
		$query = $this->db->get();
		return $query->row();
	}
	
	
	public function enablesrc($id)
	{
		$fields = array(
				'status'		=> 1
		
		);
		$this->db->set($fields);
		$this->db->where('id', $id);
		$this->db->update('vt_xuat_xu');
	}
	// END SOURCE MODEL
}

/* Location: ./application/models/source_model.php */